﻿using System;
using System.Collections.Generic;
using NthDownload.Contracts.Plugins.Downloads;

namespace NthDownload.Agent
{
    public class QueueOperation
    {
        #region Constructor

        /// <summary>
        /// Represents an operation running on a download queue
        /// </summary>
        /// <param name="actionCount">The number of actions this operation is to perform.</param>
        public QueueOperation(int actionCount)
        {
            ActionCount = actionCount;
            ActionCompletedCount = 0;
            Downloads = new List<IDownload>();

            DownloadErrors = new Dictionary<IDownload, Exception>();
            DownloadAborts = new Dictionary<IDownload, bool>();
            DownloadCancels = new Dictionary<IDownload, bool>();
        }

        #endregion Constructor

        #region Properties

        /// <summary>
        /// The number of actions this operation is to perform
        /// </summary>
        public int ActionCount { get; set; }

        /// <summary>
        /// The number of actions this has completed
        /// </summary>
        public int ActionCompletedCount { get; set; }

        /// <summary>
        /// The downloads effected by this opertion
        /// </summary>
        public IList<IDownload> Downloads { get; set; }

        /// <summary>
        /// The errors on downloads during this operation
        /// </summary>
        public IDictionary<IDownload, Exception> DownloadErrors { get; private set; }

        /// <summary>
        /// The abort values for downloads in this operation
        /// </summary>
        public IDictionary<IDownload, bool> DownloadAborts { get; private set; }

        /// <summary>
        /// The cancel values for downloads in this operation
        /// </summary>
        public IDictionary<IDownload, bool> DownloadCancels { get; private set; }

        #endregion Properties
    }
}
